home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Periodicals / develop / develop 4 code / C++ Driver / iacDriver / TDriver.h < prev    next >
Encoding:
C/C++ Source or Header  |  1990-05-28  |  2.6 KB  |  75 lines  |  [TEXT/MPS ]

  1. #ifndef     __TDriver__
  2. #define    __TDriver__
  3.  
  4. #include    "TMessage.h"
  5. #include    "IACHeaders.h"
  6.  
  7. // Because these equates aren't in SysEqu.h
  8. const        short        kRdCmd = 2;
  9. const        short        kWrCmd = 3;
  10.  
  11. const        short        kMaxApps = 16;
  12. const        short        kMaxMessages = 16;
  13.  
  14. class TDriver: public HandleObject {
  15. public:
  16.     // Constructor and destructor.
  17.             TDriver();
  18.             ~TDriver();
  19.  
  20.     /* Generic driver routines.  These are the only public interfaces we 
  21.      * show to the world.                                            */
  22.     OSErr    iacOpen(ParmBlkPtr oParmBlock);
  23.     OSErr    iacPrime(ParmBlkPtr pParmBlock);
  24.     OSErr    iacControl(ParmBlkPtr cntlParmBlock);
  25.     OSErr    iacStatus(ParmBlkPtr sParmBlock);
  26.     OSErr    iacClose(ParmBlkPtr cParmBlock);
  27.     
  28. private:
  29.     // Control Routines.
  30.     /* RegisterApp takes the string in iacRecord.appName and finds a slot in the
  31.      * array for the name (hence it "registers" the application).
  32.      * SendMessage sends a message from one application to another (as specified
  33.      * specified by the iacRecord fields.
  34.      * ReceiveMessage puts the message string into the iacRecord.msgString field
  35.      * if there's a message for the requesting application.
  36.      * UnregisterApp removes the application's name from the array (hence the 
  37.      * application is "unregistered").                                                */
  38.     short        RegisterApp(IACRecord    *anIACPtr);
  39.     short        SendMessage(IACRecord    *anIACPtr);
  40.     short        ReceiveMessage(IACRecord    *anIACPtr);
  41.     short        UnregisterApp(IACRecord    *anIACPtr);
  42.     
  43.     // Status Routines
  44.     /* WhosThere returns the signature of other applications which  
  45.      * have registered.
  46.      * AnyMessagesForMe returns the number of messages waiting for the
  47.      * reqeusting application in iacRecord.actualCount                            */
  48.     void        WhosThere(IACRecord    *anIACPtr);
  49.     Boolean    AnyMessagesForMe(IACRecord    *anIACPtr);
  50.     
  51.     // Message array handling routines.
  52.     /* GetMessage gets the TMessPtr in fMessageArray[signature]
  53.      * SetMessage sets the pointer in fMessageArray[signature] to aMsgPtr    */
  54.     TMessPtr    GetMessage(short signature);
  55.     void        SetMessage(short index, TMessPtr    aMsgPtr);
  56.     
  57.     // AppName array handling routines.
  58.     /* GetAppName gets the application name in fAppNameArray[signature]
  59.      * SetAppName sets the application in fAppNameArray[signature] 
  60.      * to anAppName    */
  61.     char        *GetAppName(short signature);
  62.     void        SetAppName(short signature, char *anAppName);
  63.     
  64.     /* We'll keep an array of applications which can register with the 
  65.      * driver.  I've arbitrarily set this at 16.  We also keep an array 
  66.      * of TMessage pointers to  passed around.  This is also arbitrarily 
  67.      * set at 16.  In the future, I'd probably implement this as a list of
  68.      * messages.                                */
  69.     char        fAppNameArray[kMaxApps] [255];
  70.     TMessPtr    fMessageArray[kMaxMessages];
  71. };
  72.  
  73.  
  74. typedef    TDriver    *TDrvrPtr;
  75. #endif